﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using sdm.exam.domain;
using sdm.exam.domain.Abstract;
using sdm.exam.domain.DataContext;

namespace sdm.exam.test.Manager
{
    [TestClass]
    public class SemesterCalcManagerTest
    {
        private SemesterCalcManager _manager = null;
        /// <summary>
        /// Initialize the test.
        /// </summary>
        [TestInitialize]
        public void Start()
        {
            Ninjector.Kernel.Bind<ISdmExamRepository>().ToConstant(new DataContext(ConnectionStrings.TestConnection));
            _manager = new SemesterCalcManager();
        }

        /// <summary>
        /// Cleanup the test.
        /// </summary>
        [TestCleanup]
        public void End()
        {
            Ninjector.Kernel.Unbind<ISdmExamRepository>();
        }

        [TestMethod]
        public void CalculateSemesterTest()
        {
            var thisYear = DateTime.Now;
            int year = thisYear.Year;

            String newYear = "01/09/" + (year - 2);

            DateTime oldYear = DateTime.Parse(newYear);

            int calcSemester = _manager.CalculateSemester(oldYear);

            Assert.AreEqual(thisYear.Month < 9 ? 4 : 5, calcSemester);
        }
    }
}